#include <stdio.h>
#include <string.h>
int main(){
    char s[1001];
    char c;
    char result[1001];
    scanf("%s",s);
    scanf(" %c",&c);
    int len = strlen(s);
    int i;
    int count=0;
    for (i=len-1;i>=0;i--){
        if (s[i]!=c){
            result[count++]=s[i];
        }
    }
    result[count]='\0';
    printf("%s\n",result);
    return 0;
}